//
//  ChooseTrunkViewController.m
//  SportRing
//
//  Created by 微他 on 15-1-16.
//  Copyright (c) 2015年 HotOne. All rights reserved.
//

#import "ChooseTrunkViewController.h"
#import "OnlyOnePickerView.h"
#import "SRDB.h"
#import "SRManager.h"

@interface ChooseTrunkViewController ()
{
    OnlyOnePickerView *_pickerView;
}
@end

@implementation ChooseTrunkViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.navigationItem.hidesBackButton = YES;
    [self addLeftStringButton:NSLocalizedString(@"上一步", nil)];
    [self addRightStringButton:NSLocalizedString(@"下一步", nil)];
    [self setCustomTitle:NSLocalizedString(@"绑定手环",nil)];
    [self initView];
}

- (void)initView
{
    _pickerView = [[OnlyOnePickerView alloc] initWithFrame:CGRectMake(0, 100, CGRectGetWidth(self.view.bounds), 260)];
//    pickerView.backgroundColor = [UIColor redColor];
    [self.view addSubview:_pickerView];
}

#pragma mark -- 下一步
-(void)onRightButtonPressed
{
    if (_pickerView.selectPerName.length > 0) {
        SRDevice * device = [SRDevice findDeviceCINEForMe:[SRMe currentUser]];
        [device configAttributesWithBlock:^(SRDevice *deviceSelf) {
            deviceSelf.name = _pickerView.selectPerName;
        }];
        [[SRManager sharedInstance] setCurrentPeripheralName:_pickerView.selectPerName];
    }
    [self performSegueWithIdentifier:@"gotoTarget" sender:self];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
